home *** CD-ROM | disk | FTP | other *** search
- class disney.rabbitRivalry.ents.Entity extends smashing.keithm.Renderable
- {
- var startSpin;
- var startVelocity;
- var owner;
- var startGravity;
- var doRemove;
- var velocity;
- var gravityVector;
- var rotation;
- var spin;
- var isSpinning;
- var __animation;
- var isAlive;
- var nextX;
- var hdReg;
- var hdWidth;
- var nextY;
- var hdHeight;
- var x;
- var y;
- var nextZ;
- var z;
- var mc;
- var __isAnimating;
- var specialDepth;
- var HAS_SPECIAL_DEPTH = false;
- var __3D_SCALE = true;
- var __IDLE_ANIMATION = "idle";
- var __DEATH_ANIMATION = "die";
- var __MAX_VELOCITY = 800;
- var __USES_VELOCITY = true;
- function Entity(t_data)
- {
- super(t_data);
- }
- function init(t_data)
- {
- if(t_data.spin != undefined)
- {
- this.startSpin = t_data.spin;
- }
- else
- {
- this.startSpin = 0;
- }
- if(t_data.vel != undefined)
- {
- this.startVelocity = t_data.vel;
- }
- else
- {
- this.startVelocity = new smashing.Point3D(0,0,0);
- }
- if(this.owner.gravity != undefined)
- {
- this.startGravity = this.owner.gravity;
- }
- else
- {
- this.startGravity = new smashing.Point3D(0,0,0);
- }
- this.doRemove = false;
- super.init(t_data);
- }
- function reset()
- {
- this.velocity = this.startVelocity.copy();
- this.gravityVector = this.startGravity.copy();
- this.rotation = 0;
- this.spin = this.startSpin;
- if(this.startSpin == 0)
- {
- this.isSpinning = false;
- }
- else
- {
- this.isSpinning = true;
- }
- super.reset();
- this.__animation = this.__IDLE_ANIMATION;
- }
- function takeDamage(power)
- {
- this.startDie();
- }
- function startDie()
- {
- this.kill();
- this.animate(this.__DEATH_ANIMATION);
- if(this.__USES_VELOCITY)
- {
- this.velocity.x = this.velocity.y = 0;
- }
- }
- function endDie()
- {
- }
- function onErase()
- {
- super.onErase();
- }
- function updateDraw(camera)
- {
- if(this.doRemove || !this.isAlive)
- {
- return undefined;
- }
- super.updateDraw(camera);
- }
- function runHD(t_target, dt)
- {
- if(!(this.isAlive && t_target.isAlive))
- {
- return false;
- }
- if(Math.abs(this.nextX + this.hdReg.x - (t_target.nextX + t_target.hdReg.x)) < this.hdWidth + t_target.hdWidth)
- {
- if(Math.abs(this.nextY + this.hdReg.y - (t_target.nextY + t_target.hdReg.y)) < this.hdHeight + t_target.hdHeight)
- {
- return true;
- }
- }
- return false;
- }
- function hitReact(t_source)
- {
- }
- function onDraw(t_newmc)
- {
- super.onDraw(t_newmc);
- this.animate(this.__IDLE_ANIMATION);
- }
- function update(dt)
- {
- this.updateAnim();
- if(this.__USES_VELOCITY)
- {
- this.nextX = this.x + this.velocity.x * dt;
- this.nextY = this.y + this.velocity.y * dt;
- this.nextZ = this.z + this.velocity.z * dt;
- }
- }
- function move(dt)
- {
- if(this.__USES_VELOCITY)
- {
- this.x += this.velocity.x * dt;
- this.y += this.velocity.y * dt;
- this.z += this.velocity.z * dt;
- }
- }
- function render(camera, dt)
- {
- super.render(camera,dt);
- }
- function moveAndRender(camera, dt)
- {
- if(this.__USES_VELOCITY)
- {
- this.nextX = this.x += this.velocity.x * dt;
- this.nextY = this.y += this.velocity.y * dt;
- this.nextZ = this.z += this.velocity.z * dt;
- }
- this.render(camera,dt);
- }
- function updateMoveAndRender(camera, dt)
- {
- this.updateAnim();
- if(this.__USES_VELOCITY)
- {
- this.nextX = this.x += this.velocity.x * dt;
- this.nextY = this.y += this.velocity.y * dt;
- this.nextZ = this.z += this.velocity.z * dt;
- }
- this.render(camera,dt);
- }
- function animate(frame)
- {
- if(frame != undefined)
- {
- this.__animation = frame;
- }
- this.mc.gotoAndStop(this.__animation);
- if(this.__animation == this.__IDLE_ANIMATION)
- {
- this.__isAnimating = false;
- }
- else
- {
- this.__isAnimating = true;
- }
- }
- function updateAnim()
- {
- if(this.__isAnimating)
- {
- if(this.mc.anim._currentFrame == this.mc.anim._totalFrames)
- {
- if(this.__animation == this.__DEATH_ANIMATION)
- {
- this.endDie();
- }
- else
- {
- this.animate(this.__IDLE_ANIMATION);
- }
- }
- }
- }
- function freezeAnimation()
- {
- this.mc.anim.stop();
- }
- function unfreezeAnimation()
- {
- if(this.__isAnimating)
- {
- this.mc.anim.play();
- }
- else
- {
- this.animate();
- }
- }
- function replaceVelocity(t_vector)
- {
- this.velocity = t_vector.copy();
- }
- function inputVelocity(t_vector)
- {
- this.velocity.x += t_vector.x;
- this.velocity.y += t_vector.y;
- this.velocity.z += t_vector.z;
- }
- function addVelocity(t_vector, dt, maxVelocity, xMult, yMult, zMult)
- {
- this.velocity.x += t_vector.x * dt;
- this.velocity.y += t_vector.y * dt;
- this.velocity.z += t_vector.z * dt;
- }
- function getIntersect_line_line(t_lineStart, t_lineEnd, dt)
- {
- var _loc4_ = undefined;
- var _loc3_ = undefined;
- var _loc7_ = undefined;
- var _loc6_ = undefined;
- var _loc5_ = undefined;
- if(this.velocity.x != 0)
- {
- _loc4_ = this.velocity.y / this.velocity.x;
- }
- else
- {
- _loc4_ = Infinity;
- }
- if(t_lineEnd.x - t_lineStart.x != 0)
- {
- _loc3_ = (t_lineEnd.y - t_lineStart.y) / (t_lineEnd.x - t_lineStart.x);
- }
- else
- {
- _loc3_ = Infinity;
- }
- _loc7_ = t_lineStart.y - _loc4_ * t_lineStart.x;
- _loc6_ = t_lineStart.y - _loc3_ * t_lineStart.x;
- _loc5_ = 1 / (_loc4_ * -1 - _loc3_ * -1);
- return new smashing.Point3D((-1 * _loc6_ - -1 * _loc7_) * _loc5_,(_loc3_ * _loc7_ - _loc4_ * _loc6_) * _loc5_);
- }
- function magnitudeToVector(t_magnitude, t_angle)
- {
- var _loc2_ = undefined;
- var _loc1_ = undefined;
- var _loc3_ = t_angle * 0.017453292519943295;
- _loc2_ = t_magnitude * Math.cos(_loc3_);
- _loc2_ = Math.round(_loc2_ * 100) / 100;
- _loc1_ = t_magnitude * Math.sin(_loc3_);
- _loc1_ = Math.round(_loc1_ * 100) / 100;
- return new smashing.Point3D(_loc2_,_loc1_,0);
- }
- function getDrawType()
- {
- return this.HAS_SPECIAL_DEPTH != true ? this.DRAWTYPE : this.DRAWTYPE + "_" + this.specialDepth;
- }
- function getIsAnimating()
- {
- return this.__isAnimating;
- }
- function setHDRegistration()
- {
- this.hdReg = {};
- this.hdReg.x = 0;
- this.hdReg.y = 0;
- }
- }
-